﻿@{
    ViewBag.Title = "LocationIndex";
}

<link href="~/Content/BootstrapSouce/css/bootstrap.css" rel="stylesheet" />
<script src="~/Content/BootstrapSouce/js/jquery.min.js"></script>
<script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>
<script src="~/Content/EasyUI/jquery.min.js"></script>

<script>




</script>

<div>
    <div class="row" style="height:50px">
        <div class="col-md-12" style="margin-top:10px;height:30px;background-color:#0094ff">

        </div>
    </div>
    <table class="table table-striped">
        <tr><td>小区四至-东至</td><td><input type="text" id="location_East" /></td></tr>
        <tr><td>小区四至-南至</td><td><input type="text" id="location_South" /></td></tr>
        <tr><td>小区四至-西至</td><td><input type="text" id="location_West" /></td></tr>
        <tr><td>小区四至-北至</td><td><input type="text" id="location_North" /></td></tr>
        <tr><td>位置环绕</td><td><select id="Position"><option value="1">二环内</option><option value="2">三环内</option><option value="3">四环内</option><option value="4">五环外</option></select></td></tr>
        <tr><td>交通情况</td><td><input type="text" id="location_Traffic" /></td></tr>
        <tr><td>交通便捷度</td><td><select id="location_Convenient"><option value="1">便捷</option><option value="2">一般</option><option value="3">拥堵</option></select></td></tr>
        <tr><td>自然人文环境情况</td><td><input type="text" id="location_Humanity" /></td></tr>
        <tr><td>自然人文环境质量</td><td><select id="location_Quality"><option value="1">优良</option><option value="2">一般</option><option value="3">低下</option></select></td></tr>
        <tr><td>居住社区情况</td><td><input type="text" id="location_Community" /></td></tr>
        <tr><td>居住社区成熟度</td><td><select id="location_Mature"><option value="1">已建好,入住情况稳定</option><option value="2">部分楼栋正在施工</option><option value="3">个别楼栋能入住</option></select></td></tr>
        <tr><td>基础设施配套情况</td><td><input type="text" id="location_Facilities" /></td></tr>
        <tr><td>基础设施配套度</td><td><select id="location_Degree"><option value="1">七通一平</option><option value="2">六通一平</option><option value="3">五通一平</option></select></td></tr>
        <tr><td>配套设置</td><td><select id="location_Supporting"><option value="1">规模大,设备齐全</option><option value="2">中等规模小区.设备齐全</option><option value="3">小型小区,设备老旧</option></select></td></tr>
        <tr><td>有关说明</td><td><textarea id="location_Explain" style="width:300px;height:60px;"></textarea></td></tr>
        <tr><td><input id="ins" type="button" value="保存" onclick="LocationAdd(1)" class="btn btn-primary" /></td><td><input id="upd" type="button" value="修改" onclick="LocationAdd(2)" class="btn btn-primary" /></td></tr>
    </table>
</div>

<script>
    $("#upd").hide();
    var urls = "http://localhost:63805/";
    var Urls = window.location.href;
    var Sums = Urls.split("=");
    var projectNumber = Sums[1];
    locations(projectNumber);
    function locations(id) {
        
        $.ajax({
            url: urls + "apis/Location/getmodel/" + id,
            dataType: "json",
            type: "get",
            success: function (obj) {
                
                if (obj != null) {
                    var location_East = $("#location_East").val(obj.location_East);   //东
                    var location_South = $("#location_South").val(obj.location_South);   //南
                    var location_West = $("#location_West").val(obj.location_West);   //西
                    var location_North = $("#location_North").val(obj.location_North);   //北
                    var location_Position = $("#Position").val(obj.location_Position);//位置环绕
                    
                    var location_Traffic = $("#location_Traffic").val(obj.location_Traffic); //交通情况
                    var location_Convenient = $("#location_Convenient").val(obj.location_Convenient); //交通便捷度
                    var location_Humanity = $("#location_Humanity").val(obj.location_Humanity); //自然人文环境情况
                    var location_Quality = $("#location_Quality").val(obj.location_Quality);   //自然人文环境质量
                    var location_Community = $("#location_Community").val(obj.location_Community); //社区成情况
                    var location_Mature = $("#location_Mature").val(obj.location_Mature);      //社区成熟情况

                    var location_Facilities = $("#location_Facilities").val(obj.location_Facilities);  //基础设施配套情况
                    var location_Degree = $("#location_Degree").val(obj.location_Degree);          //基础设施配套度
                    var location_Supporting = $("#location_Supporting").val(obj.location_Supporting);   //设施配套
                    var location_Explain = $("#location_Explain").val(obj.location_Explain);
                    $("#ins").hide();
                    $("#upd").show();
                }

            }
        })
    }//区位状况

    function LocationAdd(id) {
        var location_East = $("#location_East").val();   //东
        var location_South = $("#location_South").val();   //南
        var location_West = $("#location_West").val();   //西
        var location_North = $("#location_North").val();   //北
        var location_Position = $("#Position").val();
        //alert(location_Position);

        var location_Traffic = $("#location_Traffic").val(); //交通情况
        var location_Convenient = $("#location_Convenient").val(); //交通便捷度
        var location_Humanity = $("#location_Humanity").val(); //自然人文环境情况
        var location_Quality = $("#location_Quality").val();   //自然人文环境质量
        var location_Community = $("#location_Community").val(); //社区成情况
        var location_Mature = $("#location_Mature").val();      //社区成熟情况

        var location_Facilities = $("#location_Facilities").val();  //基础设施配套情况
        var location_Degree = $("#location_Degree").val();          //基础设施配套度
        var location_Supporting = $("#location_Supporting").val();   //设施配套
        var location_Explain = $("#location_Explain").val();         //有关说明
        if (id == 1)
        {
            $.ajax({
                type: "post",
                url: "http://localhost:63805/apis/Location/LocationShow",
                data: {
                    projectNumber: projectNumber, location_East: location_East, location_South: location_South, location_West: location_West, location_North: location_North, location_Position: location_Position,
                    location_Traffic: location_Traffic, location_Convenient: location_Convenient, location_Humanity: location_Humanity, location_Quality: location_Quality, location_Community: location_Community, location_Mature: location_Mature,
                    location_Facilities: location_Facilities, location_Degree: location_Degree, location_Supporting: location_Supporting, location_Explain: location_Explain
                },
                success: function (obj) {
                    if (obj > 0) {
                        alert("保存成功!");
                        window.history.back(-1);
                    }
                    else {
                        alert("失败!");
                    }
                }

            })
        }
        else
        {
            $.ajax({
                type: "put",
                url: "http://localhost:63805/api/Location/" + projectNumber,
                data: {
                    projectNumber: projectNumber, location_East: location_East, location_South: location_South, location_West: location_West, location_North: location_North, location_Position: location_Position,
                    location_Traffic: location_Traffic, location_Convenient: location_Convenient, location_Humanity: location_Humanity, location_Quality: location_Quality, location_Community: location_Community, location_Mature: location_Mature,
                    location_Facilities: location_Facilities, location_Degree: location_Degree, location_Supporting: location_Supporting, location_Explain: location_Explain
                },
                success: function (obj) {
                    if (obj > 0) {
                        alert("修改成功!");
                        window.history.back(-1);
                       

                        
                    }
                    else {
                        alert("失败!");
                    }
                }

            })
        }
        


    }
</script>